一旦你完成了PPAPI插件的开发,实际使用时可能会有下列需求:
- 动态创建PPAPI插件
- 删除PPAPI插件
- 改变PPAPI插件的尺寸
实现起来很简单,从JS里直接访问DOM(BOM)即可。下面是一个示例HTML文件:
<!DOCTYPE html>
<html>
<!--
Copyright (c) 2016 foruok@微信订阅号“程序视界”(programmer_sight).
All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<head>
<style type="text/css">
#pluginContainer
{
padding: 0px;
width: 1220px;
height: 540px;
background-color: gray;
}
</style>
<script type="text/javascript">
function createPlugin() {
var plugin = document.createElement("embed");
plugin.setAttribute("id", "explugin");
plugin.setAttribute("type", "application/x-ppapi-example");
plugin.setAttribute(&#